let app = getApp()
Component({
    properties: {
      tagData: {
        type:Object,
        observer: function(newVal, oldVal) {
          this.updateRate()
        }
      },requestData: {
        type:Object,
        observer: function(newVal, oldVal) {
          this.update()
        }
      }
      },
      data:{
        loginShow:false
      },
    lifetimes: {
        attached: function () {
             var that=this
             that.setData({
              intellect_tags:that.data.tagData.intellect_tags,
              tags:that.data.tagData.tags
             })
         }
      },
    methods: {
      getdelTag:function(e){
        var that=this
        var cus_id=that.data.requestData.cus_id
         wx.request({
          url: app.globalData.siteroot,
           data: {
             do:'Customer_delTag',
             staff_id:wx.getStorageSync('staff_bind_id'),
             cus_id:cus_id,
             tags:e.detail.old_tag
          },
         success: function(res) {
            that.triggerEvent('getlabelData',1)
          }
        }) 
     },
      getPopupData2:function(e){
        var that=this
        var cus_id=that.data.requestData.cus_id
         wx.request({
          url: app.globalData.siteroot,
           data: {
             do:'Customer_editTag',
             staff_id:wx.getStorageSync('staff_bind_id'),
             cus_id:cus_id,
             old_tag:e.detail.old_tag,
             new_tag:e.detail.new_tag
          },
         success: function(res) {
            that.triggerEvent('getlabelData',1)
          }
        }) 
     },
      getPopupData:function(e){
        var that=this
        var cus_id=that.data.requestData.cus_id
         wx.request({
          url: app.globalData.siteroot,
           data: {
             do:'Customer_addtag',
             staff_id:wx.getStorageSync('staff_bind_id'),
             cus_id:cus_id,
             tags:e.detail,
             tag:''
          },
         success: function(res) {
             var tags=that.data.tags
             tags.push(e.detail)
             that.setData({
              tags:tags
             })
          }
        }) 
     },
     editlabel:function(e){
      var  popup={
        tit: "请编辑标签",
        btn: [ "保存", "删除" ],
        flag: !0,
        x: !1,
        edit:1,
        label:e.currentTarget.dataset.label
     }
     this.setData({
         popup:popup
     })
    },
      addlabel:function(e){
        var  popup={
          tit: "请输入标签不超过10个字",
          btn: [ "取消", "确认" ],
          flag: !0,
          edit:0,
          x: !1
       }
       this.setData({
           popup:popup
       })
      },
      update:function(){

      },
      updateRate:function(){
           var that=this
           that.setData({
            intellect_tags:that.data.tagData.intellect_tags,
            tags:that.data.tagData.tags
           })
      }
    }
});
